<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件流的捕获阶段和冒泡阶段</title>
    <style>
        .father{
            overflow: hidden;
            width: 300px;
            height: 300px;
            margin: 100px auto;
            background-color: pink;
            text-align: center;
        }
        .son{
            width:200px;
            height: 200px;
            margin: 50px;
            background-color: purple;
            line-height: 200px;
            color:#fff;
        }
    </style>
</head>
<body>
    <div class="father">
        <div class="son">son盒子</div>
    </div>
    <script>
        //这是捕获阶段 调用事件 会先 弹出 father然后再弹出son
        var son = document.querySelector(".son")
        var father = document.querySelector(".father")
        son.addEventListener("click",function(){
            alert('son');
        },true)
        father.addEventListener("click",function(){
            alert('father')
        },true);


        //这是冒泡阶段 调用事件 会先弹出son再弹出father
        son.addEventListener("click",function(){
            alert('son');
        },false)
        father.addEventListener("click",function(){
            alert('father')
        },false);
    </script>
</body>
</html>